const { ccclass, property } = cc._decorator;

enum AgeLimit {
    八岁,
    十二岁,
    十六岁
}

@ccclass
export default class HealthAdvicePanel extends cc.Component {
    @property({ type: cc.Enum(AgeLimit), displayName: `适龄`, tooltip: `适龄限制` })
    ageLimit: AgeLimit = AgeLimit.八岁;

    @property({ displayName: `著作权人` })
    company: string = ``;

    @property({ displayName: `登记号` })
    licenseNumber: string = ``;

    ageLimitAtalsPath: string = `Sprites/Common/AgeLimit`;

    start() {
        this.node.getChildByName(`CompanyLb`).getComponent(cc.Label).string = `${this.company}`;
        this.node.getChildByName(`LicenseLb`).getComponent(cc.Label).string = `${this.licenseNumber}`;

        //适龄提示角标
        let ageLimitSp: cc.Sprite = this.node.getChildByName(`AgeLimitSp`).getComponent(cc.Sprite);
        switch (this.ageLimit) {
            case AgeLimit.八岁:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`8`);
                });
                break;
            case AgeLimit.十二岁:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`12`);
                });
                break;
            case AgeLimit.十六岁:
                cc.loader.loadRes(this.ageLimitAtalsPath, cc.SpriteAtlas, (err, res: cc.SpriteAtlas) => {
                    ageLimitSp.spriteFrame = res.getSpriteFrame(`16`);
                });
                break;
        }
    }

}
